<?php
/**
 * A simple description for this script
 *
 * PHP Version 5.2.0 or Upper version
 *
 * @package    Paylog
 * @author     Hidehito NOZAWA aka Suin <http://suin.asia>
 * @copyright  2010 Hidehito NOZAWA
 * @license    http://www.gnu.org/licenses/gpl-2.0.html GNU GPL v2
 *
 */

class Paylog_Object_RelBalanceTagHandler extends Paylog_Abstract_ObjectHandler
{
	protected $object  = 'Paylog_Object_RelBalanceTag';
	protected $table   = 'rel_balance_tag';
	protected $primary = 'id';

	public function loadTagIdsByBalanceId($id)
	{
		$id = intval($id);
		$sql = "select `tag_id` from `%s` where `balance_id`='%u'";
		$sql = sprintf($sql, $this->table, $id);
		$rsrc = $this->_query($sql);

		$tagIds = array();

		while ( list($tagId) = $this->db->fetchRow($rsrc) )
		{
			$tagIds[] = $tagId;
		}

		return $tagIds;
	}

	public function deleteByBalanceId($balanceId)
	{
		$balanceId = intval($balanceId);
		$sql = "DELETE FROM `%s` WHERE `balance_id` = '%u'";
		$sql = sprintf($sql, $this->table, $balanceId);

		return $this->db->query($sql);
	}
}

?>
